package com.houtai.controller.resume;


import com.houtai.authority.Authority;
import com.houtai.authority.AuthorityType;
import com.houtai.bean.TsJzAdmin;
import com.houtai.bean.dto.resume.TdResumeListDto;
import com.houtai.service.funcion.FuncionService;
import com.houtai.service.resume.ResumeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * Created by lizhun on 2017/7/19.
 */
@Controller
@RequestMapping(value = {"v5"})
public class ResumeController {
    @Resource
    private ResumeService resumeService;
    @Autowired
    private RedisTemplate redisTemplate;
    @Resource
    private FuncionService funcionService;
 
    /**
     * @Purpose  查找简历列表
     * @version  1.0
     * @author   lizhun
     * @param    request
     * @return   RetInfo
     */
    @RequestMapping(value="/resume/list")
    @Authority(AuthorityType.Login)
    public ModelAndView list(HttpServletRequest request, TdResumeListDto page){
        ModelAndView mv = new ModelAndView("resume/list");
        mv.addObject("retInfo", resumeService.findTdResume(page, request));
        mv.addObject("token", request.getParameter("token"));
        mv.addObject("father_id", request.getParameter("father_id"));
        TsJzAdmin tsJzAdmin = (TsJzAdmin) redisTemplate.opsForValue().get(request.getParameter("token")) ;
        mv.addObject("funcions", funcionService.findSonFuncion(tsJzAdmin, Integer.valueOf(request.getParameter("father_id"))));
        return mv;
    }


    /**
     * @Purpose  简历详情
     * @version  1.0
     * @author   lizhun
     * @param    request
     * @return   RetInfo
     */
    @RequestMapping(value="/resume/detail")
    @Authority(AuthorityType.Login)
    public ModelAndView detail(HttpServletRequest request, Integer resume_id){
        ModelAndView mv = new ModelAndView("resume/detail");
        mv.addObject("retInfo", resumeService.findTdResume(resume_id, request));
        return mv;
    }
}
